package mightyMarket.database;
import com.db4o.*;
import com.db4o.query.Query;

import java.util.*;

public class DataService 
{
	ObjectContainer db;
	
	public <T> void SaveObject(T object)
	{
		db.store(object);
	}
	
	public <T> List<T> GetObjects(Class<T> classType) 
	{
		Query query=db.query();
		query.constrain(classType);
		return query.execute(); 
	}
	
	public void OpenDb()
	{
		db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), "testDb");
	}
	
	public void CloseDb() 
	{
		db.close();		
	}
}
